public class sumOver {
    public void sum(int N)throws Exception{
        int sum = 0;
        for (int i = 0; i <= N; i++) {
            sum +=i;
        }
        if(sum>=500){
            System.out.println("sum = "+sum);
            throw new RuntimeException("结果大于500");
        }
        System.out.println("sum = "+sum);
    }
}
